//
//  UIView+ShowMsg.m
//  提示语_心之寻
//
//  Created by Burn on 2019/3/28.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "UIView+ShowMsg.h"
#import "ShowMsg.h"
#import <objc/runtime.h>


@implementation UIView (ShowMsg)

const static char showMsgViewKey;

- (void)showMsg:(NSString *)msg{
    self.showMsgView = nil;
    ShowMsg *showMsg = [[ShowMsg alloc]init];
    showMsg.backgroundColor = [UIColor redColor];
    [showMsg showInView:self msg:msg];
    self.showMsgView = showMsg;
}




- (UIView *)showMsgView
{
    return objc_getAssociatedObject(self, &showMsgViewKey);
}

- (void)setShowMsgView:(UIView *)errorView{
    objc_setAssociatedObject(self, &showMsgViewKey, errorView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)msghiden{
    if (self.showMsgView) {
        [self.showMsgView dismiss];
        self.showMsgView = nil;
    }
}



@end
